<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ include file="/pages/jsp/internal/include.jsp" %>

<div class="inner_cont" > 
	<h2><fmt:message key="label.userRelatedList"/></h2>
	
	<span class="note">
	
		<fmt:message key="page.relateUser.description"/>
		
		<c:forEach items="${model.messages}" var="message">
			<div id="message"><fmt:message key="${message}"/></div>
		</c:forEach>
		
		<c:forEach items="${model.errors}" var="error">
			<div id="error">
				<fmt:message key="${error.key}">
					<fmt:param value="${error.param1}"/>
				</fmt:message>
			</div>
		</c:forEach>
	</span>
	<!-- UTENTI DA ASSOCIARE -->
	
	<c:if test="${not empty model.users}">
	
		<form  id="manageUserForm" method="post" class="form">
		
			<input type="hidden" name="contentId" value="<c:out value="${model.contentId}"/>"/>
			
			<table id="tableRelateUser" class="tableDati col tablesorter" >
				<thead>
					<tr>
						<th ><fmt:message key="th.id"/></th>
			   			<th ><fmt:message key="th.mail"/></th>
			   			<th ><fmt:message key="th.pwd"/></th>
						<th ><fmt:message key="th.startDate"/></th>
						<th ><fmt:message key="th.activationCode"/></th>
						<th ><fmt:message key="th.newsLetter"/></th>
						<th ><fmt:message key="th.admin"/></th>
			   		</tr>
			   	</thead>
			   	<tfoot>
			   		<tr>
						<th><fmt:message key="th.id"/></th>
			   			<th ><fmt:message key="th.mail"/></th>
			   			<th ><fmt:message key="th.pwd"/></th>
						<th ><fmt:message key="th.startDate"/></th>
						<th ><fmt:message key="th.activationCode"/></th>
						<th ><fmt:message key="th.newsLetter"/></th>
						<th><fmt:message key="th.admin"/></th>
			   		</tr>
			   	</tfoot>
			   	
			   	<tbody>
					<c:forEach items="${model.users}" var="user" varStatus="i">
						<tr>
							<td style="text-align:center"> <input type="checkbox" name="userId" value="<c:out value="${user.id}"/>"> </td>
					   		<td> <c:out value="${user.mail}"/> </td>
							<td><c:out value="${user.pwd}"/></td>
							<td><fmt:formatDate pattern="dd/MM/yyyy" value="${user.startDate}"/></td>
							<td><c:out value="${user.activationCode}"/></td>
							<td><c:out value="${user.newsLetter}"/></td>
							<td><c:out value="${user.admin}"/></td>
					   	</tr>
					 </c:forEach>
				 </tbody>
			</table>
			
			<div  id="pagerUser" style="position:relative;top:0px">
				<form>
					<img src="<c:url value="/js/table/first.png"/>" class="first"/>
					<img src="<c:url value="/js/table/prev.png"/>" class="prev"/>
					<input type="text" class="pagedisplay"/>
					<img src="<c:url value="/js/table/next.png"/>" class="next"/>
					<img src="<c:url value="/js/table/last.png"/>" class="last"/>
					<select class="pagesize">
						<option selected="selected" value="5">5</option>
						<option  value="10">10</option>
						<option value="20">20</option>
						<option value="30">30</option>
						<option value="40">40</option>
					</select>
				</form> 
			</div>
			
			<br/>
			
			<div class="action_bar">
				<input type="button" class ="puls" value="Associa" onclick="sendFormForAction('<c:url value="/content/manageRelationUser.htm"/>','manageUserForm','hasPrivateDiv','createRelation');"/>
			</div>
		</form>
	</c:if>
</div>
	
<div class="inner_cont" > 	
	<!-- UTENTI ASSOCIATI -->
	
	<c:if test="${not empty model.relatedUser}">
	
		<h2><fmt:message key="label.userRelatedToContent"/></h2>
		
		<form  id="manageUserRelatedForm" method="post">
			<input type="hidden" name="contentId" value="<c:out value="${model.contentId}"/>"/>
			
			<table id="tableRelatedToContent" class="tableDati col tablesorter">
				<thead>
					<tr>
						<th><fmt:message key="th.id"/></th>
			   			<th><fmt:message key="th.mail"/></th>
			   			<th><fmt:message key="th.pwd"/></th>
						<th><fmt:message key="th.startDate"/></th>
						<th><fmt:message key="th.activationCode"/></th>
						<th><fmt:message key="th.newsLetter"/></th>
						<th><fmt:message key="th.admin"/></th>
			   		</tr>
			   	</thead>
			   	<tfoot>
			   		<tr>
						<th><fmt:message key="th.id"/></th>
			   			<th><fmt:message key="th.mail"/></th>
			   			<th><fmt:message key="th.pwd"/></th>
						<th><fmt:message key="th.startDate"/></th>
						<th><fmt:message key="th.activationCode"/></th>
						<th><fmt:message key="th.newsLetter"/></th>
						<th><fmt:message key="th.admin"/></th>
			   		</tr>
			   	</tfoot>
			   	
			   <tbody>
					<c:forEach items="${model.relatedUser}" var="relatedUser" varStatus="i">
						<tr>
							<td><input type="checkbox" name="userId" value="<c:out value="${relatedUser.id}"/>"></td>
					   		<td><c:out value="${relatedUser.mail}"/></td>
							<td><c:out value="${relatedUser.pwd}"/></td>
							<td><fmt:formatDate pattern="dd/MM/yyyy"  value="${relatedUser.startDate}"/></td>
							<td><c:out value="${relatedUser.activationCode}"/></td>
							<td><c:out value="${relatedUser.newsLetter}"/></td>
							<td><c:out value="${relatedUser.admin}"/></td>
					   	</tr>
					</c:forEach>
				</tbody>
				
			</table>
			<div  id="pagerUserAssociated" style="position:relative;top:0px">
				<form>
					<img src="<c:url value="/js/table/first.png"/>" class="first"/>
					<img src="<c:url value="/js/table/prev.png"/>" class="prev"/>
					<input type="text" class="pagedisplay"/>
					<img src="<c:url value="/js/table/next.png"/>" class="next"/>
					<img src="<c:url value="/js/table/last.png"/>" class="last"/>
					<select class="pagesize">
						<option selected="selected" value="10">10</option>
						<option value="20">20</option>
						<option value="30">30</option>
						<option value="40">40</option>
					</select>
				</form> 
			</div>
			<br/>
			<div class="action_bar">
				<input type="button" class="puls" value="Elimina Associazione" onclick="sendFormForAction('<c:url value="/content/manageRelationUser.htm"/>','manageUserRelatedForm','hasPrivateDiv','deleteRelation');"/>
			</div>
		</form>
	</c:if>
</div>

<script>
$(document).ready(function() { 
	$("#tableRelateUser").tablesorter({
			widthFixed: true,
			dateFormat: "uk"
	}).tablesorterPager({
		container: $("#pagerUser"),
		size:'5'
	});
	
	$("#tableRelatedToContent").tablesorter({
		widthFixed: true,
		dateFormat: "uk"
	}).tablesorterPager({
		container: $("#pagerUserAssociated"),
		size:'5'
	});
});

</script>
